package helper.scxml.strategy

import helper.scxml.strategy.ZoneStrategyHelper.DifferenceBoundsMatrix
import helper.scxml.strategy.ZoneStrategyHelper.DifferenceBoundsMatrix.Companion.getDifferenceBoundsMatrix
import org.junit.Test

internal class ZoneStrategyHelperTest {
    @Test
    fun hashSet_sort_t1() {
        val arrayListOf = arrayListOf(6, 1, -1, 2, 3, 4, 2, 3, 5)
        val hashSetOf = HashSet<Int>()
        hashSetOf.addAll(arrayListOf)
        println(arrayListOf)
        println(hashSetOf)
        println(hashSetOf.first())
    }

    fun getDifferenceBoundsMatrix1(): DifferenceBoundsMatrix {
        return getDifferenceBoundsMatrix(4).apply {
            doubleMatrix[0, 1] = 2
            doubleMatrix[0, 2] = 4
            doubleMatrix[0, 3] = 8
            doubleMatrix[1, 0] = 5
            doubleMatrix[1, 2] = 3
            doubleMatrix[1, 3] = 1
            doubleMatrix[2, 0] = 10
            doubleMatrix[2, 1] = 7
            doubleMatrix[2, 3] = 2
            doubleMatrix[3, 0] = 9
            doubleMatrix[3, 1] = 6
            doubleMatrix[3, 2] = 3
        }
    }

    fun getDifferenceBoundsMatrix2(): DifferenceBoundsMatrix {
        return getDifferenceBoundsMatrix(4).apply {
            doubleMatrix[0, 1] = 6
            doubleMatrix[0, 2] = 4
            doubleMatrix[0, 3] = 8
            doubleMatrix[1, 0] = 5
            doubleMatrix[1, 2] = 3
            doubleMatrix[1, 3] = 1
            doubleMatrix[2, 0] = 10
            doubleMatrix[2, 1] = 7
            doubleMatrix[2, 3] = 2
            doubleMatrix[3, 0] = 9
            doubleMatrix[3, 1] = 6
            doubleMatrix[3, 2] = 3
        }
    }

    @Test
    fun matrix1_t1() {
        val matrix = getDifferenceBoundsMatrix1()
        val str = matrix.toStr()
        matrix.doubleMatrix.print()
        println(str)
        println(matrix.check())
    }

    @Test
    fun matrix2_t1() {
        val matrix = getDifferenceBoundsMatrix2()
        val str = matrix.toStr()
        matrix.doubleMatrix.print()
        println(str)
        println(matrix.check())
    }

    @Test
    fun matrix1_t2() {
        val matrix = getDifferenceBoundsMatrix1()
        val str = matrix.toStr()
        matrix.doubleMatrix.print()
        println(str)
        matrix.ifInZone(
            1,
            3,
        ).let {
            println(it)
        }
    }
}